package com.ruoyi.member.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.member.domain.MemberWalletLog;
import com.ruoyi.member.service.IMemberWalletLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员钱包流水Controller
 *
 * @author ruoyi
 * @date 2025-01-29
 */
@RestController
@RequestMapping("/member/walletLog")
public class MemberWalletLogController extends BaseController
{
    @Autowired
    private IMemberWalletLogService memberWalletLogService;

    /**
     * 查询会员钱包流水列表
     */
    @PreAuthorize("@ss.hasPermi('member:walletLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberWalletLog memberWalletLog)
    {
        startPage();
        List<MemberWalletLog> list = memberWalletLogService.selectMemberWalletLogList(memberWalletLog);
        return getDataTable(list);
    }

    /**
     * 导出会员钱包流水列表
     */
    @PreAuthorize("@ss.hasPermi('member:walletLog:export')")
    @Log(title = "会员钱包流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberWalletLog memberWalletLog)
    {
        List<MemberWalletLog> list = memberWalletLogService.selectMemberWalletLogList(memberWalletLog);
        ExcelUtil<MemberWalletLog> util = new ExcelUtil<MemberWalletLog>(MemberWalletLog.class);
        util.exportExcel(response, list, "会员钱包流水数据");
    }

    /**
     * 获取会员钱包流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:walletLog:query')")
    @GetMapping(value = "/{memberWalletLogId}")
    public AjaxResult getInfo(@PathVariable("memberWalletLogId") Integer memberWalletLogId)
    {
        return success(memberWalletLogService.selectMemberWalletLogByMemberWalletLogId(memberWalletLogId));
    }

    /**
     * 新增会员钱包流水
     */
    @PreAuthorize("@ss.hasPermi('member:walletLog:add')")
    @Log(title = "会员钱包流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberWalletLog memberWalletLog)
    {
        return toAjax(memberWalletLogService.insertMemberWalletLog(memberWalletLog));
    }
}
